// FB Alpha - Emulator for MC68000/Z80 based arcade games
//            Refer to the "license.txt" file for more info

#ifndef BURNER_H
#define BURNER_H

#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <ctype.h>

#include "title.h"
#include "burn.h"

#include "utility.h"

// Macro to make quoted strings
#define MAKE_STRING_2(s) #s
#define MAKE_STRING(s) MAKE_STRING_2(s)

#define BZIP_MAX (8)								// Maximum zip files to search through
#define DIRS_MAX (14)								// Maximum number of directories to search

#define DEFAULT_IMAGE_WIDTH		(304)
#define DEFAULT_IMAGE_HEIGHT	(224)

// ---------------------------------------------------------------------------
// OS dependent functionality

#if defined (_WIN32)
 #include "burner_win32.h"
#endif

// ---------------------------------------------------------------------------
// OS independent functionality

#include "interface.h"
#include "archive.h"
#include "misc.h"
#ifndef NO_AUTOFIRE
#include "autofire.h"
#endif

// gami.cpp
extern GameInp* gameInput;
extern unsigned int gameInpCount;
extern unsigned int macroCount;
extern unsigned int maxMacro;

extern int analogSpeed;
extern int fireButtons;

extern bool sfLayout;
extern bool leftAltkeyMapped;

int gameInpInit();
int gameInpExit();
wchar_t* inputCodeDesc(int c);
wchar_t* inpToDesc(GameInp* pgi);
wchar_t* inpMacroToDesc(GameInp* pgi);
void gameInpCheckLeftAlt();
void gameInpCheckMouse();
int gameInpBlank(int dipSwitch);
int gameInputAutoIni(int nPlayer, wchar_t* lpszFile, bool overWrite);
int gameInpDefault();
int gameInpWrite(FILE* h, bool writeConst = true);
int gameInpRead(wchar_t* szVal, bool overWrite);
int gameInpMacroRead(wchar_t* szVal, bool overWrite);
int gameInpCustomRead(wchar_t* szVal, bool overWrite);

// Player Default Controls
extern int playerDefaultControls[4];
extern wchar_t playerDefaultIni[4][MAX_PATH];

// cong.cpp
extern const int configMinVersion;					// Minimum version of application for which input files are valid
int configGameLoad(bool overWrite);				// char* lpszName = NULL
int configGameSave(bool save);

// gamc.cpp
int gamcMisc(GameInp* pgi, const char* szi, int nPlayer);
int gamcAnalogKey(GameInp* pgi, const char* szi, int nPlayer, int nSlide);
int gamcAnalogJoy(GameInp* pgi, const char* szi, int nPlayer, int nJoy, int nSlide);
int gamcPlayer(GameInp* pgi, const char* szi, int nPlayer, int nDevice);
int gamcPlayerHotRod(GameInp* pgi, const char* szi, int nPlayer, int nFlags, int nSlide);

// dat.cpp
int createDatFile(const wchar_t* filename, FILE* file = 0);

// sshot.cpp
int makeScreenShot(bool screenShot = true);

// state.cpp
int BurnStateLoadEmbed(FILE* fp, int nOffset, int bAll, int (*pLoadGame)());
int BurnStateLoad(wchar_t* szName, int bAll, int (*pLoadGame)());
int BurnStateSaveEmbed(FILE* fp, int nOffset, int bAll);
int BurnStateSave(wchar_t* szName, int bAll);

// statec.cpp
int BurnStateCompress(unsigned char** pDef, int* pnDefLen, int bAll);
int BurnStateDecompress(unsigned char* Def, int nDefLen, int bAll);

// for changing sound track
void NeoZ80Cmd(UINT16 sound_code);
void CpsSoundCmd(UINT16 sound_code);
void QSoundCMD(UINT16 sound_code);

#endif
